import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { DeleteLetterDTO, GetLetterDetailDTO, GetUserLetterListDTO, InsertLetterDTO, InsertLetterImageDTO, UpdateLetterDTO } from './letter.dto';
import { LetterService } from './letter.service';

@Controller({
  path: 'wechat/letter',
  version: '1',
})
@ApiTags('情书百封')
export class LetterController {
  constructor(private readonly letterService: LetterService) {}

  @Post('insertLetterImage')
  @ApiOperation({ summary: '新增情书时插入图片接口' })
  insertLetterImage(@Body() insertLetterImage:InsertLetterImageDTO){
    return this.letterService.insertLetterImage(insertLetterImage.ImageData)
  }

  @Post('insertLetter')
  @ApiOperation({ summary: '新增情书' })
  insertLetter(@Body() insertLetter:InsertLetterDTO){
    return this.letterService.insertLetter(insertLetter)
  }

  @Post('updateLetter')
  @ApiOperation({ summary: '修改情书' })
  updateLetter(@Body() updateLetter:UpdateLetterDTO){
    return this.letterService.updateLetter(updateLetter)
  }

  @Post('deleteLetter')
  @ApiOperation({ summary: '删除情书' })
  deleteLetter(@Body() deleteLetter:DeleteLetterDTO){
    return this.letterService.deleteLetter(deleteLetter)
  }

  @Get('getUserLetterList')
  @ApiOperation({ summary: '获取用户情书信息' })
  async getUserLetterList(@Query() getUserLetterList:GetUserLetterListDTO){
    return await this.letterService.getUserLetterList(getUserLetterList)
  }

  @Get('getLetterDetail')
  @ApiOperation({ summary: '获取情书详情' })
  async getLetterDetail(@Query() getLetterDetail:GetLetterDetailDTO){
    return await this.letterService.getLetterDetail(getLetterDetail)
  }
}
